<%@page import="qualomelhor.database.*"%>
<%@page import="qualomelhor.server.DAO"%>
<%@page import="java.util.ArrayList"%>

<%
	DAO d = new DAO();

	ArrayList<PosicaoMaosDB> listPosicaoMaos = d.getListaPosicaoMaos();
	ArrayList<ExpressaoDB> listExpressao = d.getListaExpressaoDB();
	ArrayList<SequenciaExpressaoDB> listSeqExpressao = d.getListaSequenciaExpressaoDB();
%>

<style>
	input {
		font-size: 9px;
		margin: 0px;
		padding: 0px;
	}
	select {
		font-size: 9px;
		margin: 0px;
		padding: 0px;
	}
</style>

<script type="text/javascript">
	pagina = "testegame";
	//alert("pagina em testeGame.jsp = " + pagina);
	var game = null;
	var bezierXD = 200;
	var bezierYD = 180;
	var bezierXE = 210;
	var bezierYE = 130;
	var maoId = 1;
	var subMaoDId = 1;
	var subMaoEId = 1;
	var posMDX = 0;
	var posMDY = 0;
	var posMEX = 0;
	var posMEY = 0;
	var rotAdicionalMD = 0;
	var rotAdicionalME = 0;

	function iniciarComportamentoAleatorio() {
		window.iniciaComportamentoAleatorio_j(2000);
	}

	function salvaPosicaoM() {
		var nome = document.getElementsByName("txtNomePM")[0].value;
		alert("vai salvar a posicao maos..." + nome);
		window.salvaPosicaoMao_j(nome);
	}

	function startRecording() {
		messageBox("Iniciando nova gravacao...");
		window.setRecording_j(true);
	}

	function adicionarMaisPontos() {
		window.setRecording_j(false);
	}

	function startCorrecao() {
		alert("iniciando Correcao...");
		window.setCorrigindo_j();
	}

	function selectAll(i) {
		//alert("(i, numExpressoes) = (" + i + ", " + numExpressoes + ")");
		if (window.variavelCarregamento == -1) {
			alert("Erro ao carregar as sequencias...");
			return;
		}

		if (window.variavelCarregamento == 1) {
			if (i < numExpressoes) {
				var checkB = document.getElementsByName("ckExprTmp_" + i)[0];
				checkB.checked = true;
				window.variavelCarregamento = 0;
				messageBox("Carregando sequencia: " + i);
				adicionaExpressaoAtual(i, checkB);
				window.setTimeout("selectAll(" + (++i) + ");", 200);
			} else {
				//alert("Todos os itens foram marcados!");
				playSequenciaTemp();
			}
		} else {
			messageBox("Aguardando expressao temporaria: " + i);
			window.setTimeout("selectAll(" + (i) + ");", 200);
		}
	}

	function salvaSequenciaExpressao() {
		var nome = document.getElementsByName("txtNomeSequenciaExpressao")[0].value;
		var restart = document.getElementsByName("ckRestartSeqExpr")[0].checked;
		var tempoRestart = document.getElementsByName("txtTempoRestartSeqExpr")[0].value;
		if (tempoRestart == "") {
			tempoRestart = 0;
		}
		var frameRestart = document.getElementsByName("txtFrameRestartSeqExpr")[0].value;
		if (frameRestart == "") {
			frameRestart = 0;
		}
		alert("vai salvar a sequenciaExpressao..." + nome + ", restart = " + restart + ", tempoRestart = " + tempoRestart + ", frameRestart = " + frameRestart);
		window.salvaSequenciaExpressao_j(nome, restart, tempoRestart, frameRestart);
	}

	function salvaReestartSequenciaExpressao(ckRestart) {
		var nome = document.getElementsByName("txtNomeSequenciaExpressao")[0].value;
		var restart = ckRestart.checked;
		var tempoRestart = document.getElementsByName("txtTempoRestartSeqExpr")[0].value;
		if (tempoRestart == "") {
			tempoRestart = 0;
		}
		var frameRestart = document.getElementsByName("txtFrameRestartSeqExpr")[0].value;
		if (frameRestart == "") {
			frameRestart = 0;
		}
		alert("vai salvar a sequenciaExpressao..." + nome + ", restart = " + restart + ", tempoRestart = " + tempoRestart + ", frameRestart = " + frameRestart);
		window.salvaSequenciaExpressao_j(nome, restart, tempoRestart, frameRestart);
	}

	function gravaSequenciaGravacao() {
		var nome = document.getElementsByName("txtNomeSequenciaGravacao")[0].value;

		alert("vai salvar a sequencia_gravacao..." + nome);
		window.gravaExpressaoRecording_j(nome);
	}

	function salvaExpressao() {
		var nome = document.getElementsByName("txtNomeExpressao")[0].value;
		alert("vai salvar a expressao..." + nome);
		window.salvaExpressao_j(nome, false);
	}

	function salvaExpressaoInd(indice, subMaoDId, subMaoEId, pMDX, pMDY, pMEX, pMEY, bDBezierX, bDBezierY, bEBezierX, bEBezierY) {
		var nome = document.getElementsByName("txtNomeExpr_" + indice)[0].value;
		var tempo = document.getElementsByName("txtTempo_" + indice)[0].value;
		var velocD = document.getElementsByName("txtVelocD_" + indice)[0].value;
		var velocE = document.getElementsByName("txtVelocE_" + indice)[0].value;
		var riscarD = document.getElementsByName("ckRiscarD_" + indice)[0].checked;
		var riscarE = document.getElementsByName("ckRiscarE_" + indice)[0].checked;
		var posOlhoId = document.getElementsByName("cbOlho_" + indice)[0].value;
		var movSobrancelhaId = document.getElementsByName("cbSobrancelha_" + indice)[0].value;
		var posBocaId = document.getElementsByName("cbBoca_" + indice)[0].value;
		var rotAdicMD = document.getElementsByName("rotMD_" + indice)[0].value;
		var rotAdicME = document.getElementsByName("rotME_" + indice)[0].value;
		var animar = document.getElementsByName("ckAnimar_" + indice)[0].value;
		alert("vai salvar a expressao..." + nome + ", tempo = " + tempo + ", velocD = " + velocD + ", velocE = " + velocE + ", riscarD = " + riscarD + ", riscarE = " + riscarE);
		window.salvaExpressao_j(nome, tempo, posOlhoId, posBocaId, movSobrancelhaId, subMaoDId, subMaoEId, pMDX, pMDY, pMEX, pMEY, bDBezierX, bDBezierY, bEBezierX, bEBezierY, rotAdicMD, rotAdicME, velocD, velocE, riscarD, riscarE, animar);
	}

	/*
	function adicionaExpressaoAtual() {
		var tempo = document.getElementsByName("txtTempo")[0].value;
		var velocD = document.getElementsByName("txtVelocD_" + indice)[0].value;
		var velocE = document.getElementsByName("txtVelocE_" + indice)[0].value;
		alert("vai adicionar a expressao...tempo = " + tempo);
		window.addTmpSeqExpr_j(tempo);
	}
	*/

	function addPosicaoBoneco(x, y) {
		window.addPosicaoBoneco_j(x, y);
		//alert("x = " + x + ", y = " + y);
	}

	function adicionaExpressaoAtual(indice, checkbox) {
		var tempo = document.getElementsByName("txtTempo_" + indice)[0].value;
		if (tempo == "") {
			tempo = "1";
		}
		var animar = document.getElementsByName("ckAnimar_" + indice)[0].value;
		//alert("vai adicionar a expressao...tempo = " + tempo);
		var title = checkbox.title;
		//alert("expressao nome:" + title);
		window.addSeqExpr_j(title, tempo, animar);
	}

	function playSequenciaTemp() {
		//alert("playing..");
		window.playTmpSeqExpr_j();
	}

	function deletaPosicaoM() {
		var nome = document.getElementsByName("cbPosicaoMaosDB")[0].value;
		alert("vai deletar a posicao maos..." + nome);
		window.deletaPosicaoMao_j(nome);
	}

	function deletaTodasPosicoesMaos() {
		alert("deletando tudo...");
		window.deletaTodasPosicoesMaos_j();		
	}

	function deletaTodasExpressoes() {
		if (confirm("Deletar todas as expressoes?")) {;
			window.deletaTodasExpressoes_j();
		}
	}

	function deletaExpressao() {
		var nome = document.getElementsByName("cbExpressaoDB")[0].value;
		alert("vai deletar a Expressao..." + nome);
		window.deletaExpressao_j(nome);
	}

	function carregaPosicaoM(combo) {
		var nome = combo.options[combo.selectedIndex].value;
		window.carregaPosicaoMao_j(nome);		
	}

	function carregaExpressao(combo) {
		var nome = combo.options[combo.selectedIndex].value;
		window.carregaExpressao_j(nome);		
	}

	function carregaSequenciaExpressao(combo) {
		var nome = combo.options[combo.selectedIndex].value;
		window.carregaSequenciaExpressao_j(nome, true);		
	}

	function editarSequenciaExpressao(combo) {
		var nome = combo.options[combo.selectedIndex].value;
		window.editarSequenciaExpressao_j(nome);		
	}

	function editarSequenciaTemp() {
		if (numExpressoes > 0) {
			window.editarSequenciaTemp_j();
			var nome = document.getElementsByName("txtNomeExpr_0")[0].value;
			alert(nome);
			document.getElementsByName("txtNomeSequenciaGravacao")[0].value = nome.substring(0, nome.indexOf("_"));
		}
	}

	function carregaExpressaoByName(nome) {
		window.carregaExpressao_j(nome);
	}

	function trImagem() {
		window.trocaImagem();
	}

	function trocaPosMaos(combo) {
		//alert("combo seleted index = " + combo.selectedIndex);
		window.trocaMaos(combo.options[combo.selectedIndex].value);
		//escrevePosicao();
	}

	function trPosicaoBoca(combo) {
		//alert("boca = " + combo.options[combo.selectedIndex].value);
		window.trocaPosicaoBoca_j(combo.options[combo.selectedIndex].value);
	}

	function trocaRiscar(checkRiscar) {
		alert("checkRiscar = " + checkRiscar.checked);
		window.setRiscar_j(checkRiscar.checked);
	}

	function trPosicaoOlho(combo) {
		//alert("olho = " + combo.options[combo.selectedIndex].value);
		window.trocaPosicaoOlho_j(combo.options[combo.selectedIndex].value);
	}

	function trSobrancelha(combo) {
		//alert("sobrancelha = " + combo.options[combo.selectedIndex].value);
		window.trocaSobrancelha_j(combo.options[combo.selectedIndex].value);
	}

	function trocaSeqExpressao(combo) {
		window.trocaSequenciaExpressao(combo.options[combo.selectedIndex].value);
		escreveExpressao();
	}

	function trocaPosExpressao(combo) {
		//alert("combo seleted index = " + combo.selectedIndex);
		window.trocaExpressao(combo.options[combo.selectedIndex].value);
		escreveExpressao();
	}

	function trocaAnimAleatoria(combo) {
		window.iniciaAleatorio(combo.options[combo.selectedIndex].value);
		escreveExpressao();
	}

	function trocaEstiloMao(combo) {
		estiloMao = combo.options[combo.selectedIndex].value;
		window.setEstiloMao_j(estiloMao);		
	}

	function trocaSubMao(maoAtual, combo) {
		if (maoAtual == 1) {
			subMaoDId = combo.options[combo.selectedIndex].value;
			window.setSubMaoD_j(subMaoDId);
		} else {
			subMaoEId = combo.options[combo.selectedIndex].value;
			window.setSubMaoE_j(subMaoEId);			
		}
	}

	function trocaEstiloMaoAET(combo) {
		trocaEstiloMao(combo);
		alteraExpressaoTmp();
	}

	function trocaSubMaoIdAET(combo) {
		var maoAtual = document.getElementsByName("txtAET_Mao")[0].value;
		//alert("maoatual = " + maoAtual); 
		trocaSubMao(maoAtual, combo);
		alteraExpressaoTmp();
	}

	function bezierE(x, y) {
		bezierXE += x;
		bezierYE += y;
		//alert("alterou bezier = " + bezierX + ", " + bezierY);
		document.getElementsByName("txtXE")[0].value = bezierXE;
		document.getElementsByName("txtYE")[0].value = bezierYE;
		//alert("alterou bezier = " + bezierX + ", " + bezierY);
		//escrevePosicao();
		window.setBezierE(x, y);
	}

	function escrevePosicao() {
		//alert("escreveposicao");
		var str = "NOVA_POSICAO(*, " + maoDId + ", " + maoEId + ", " + posMDX + ", " + posMDY + ", " + posMEX + ", " + posMEY + ", " + bezierXD + ", " + bezierYD + ", " + bezierXE + ", " + bezierYE + ", " + rotAdicionalMD + ", " + rotAdicionalME + "),";
		//alert ("str = " + str);
		document.getElementsByName("txtNovaPosicao")[0].value = str;
	}

	function escreveExpressao() {
		//alert("escreveposicao");
		var str = "NOVA_Expressao(*, ),";
		//alert ("str = " + str);
		document.getElementsByName("txtNovaExpressao")[0].value = str;
	}

	function bezierD(x, y) {
		bezierXD += x;
		bezierYD += y;
		//alert("alterou bezier = " + bezierX + ", " + bezierY);
		document.getElementsByName("txtXD")[0].value = bezierXD;
		document.getElementsByName("txtYD")[0].value = bezierYD;
		//alert("alterou bezier = " + bezierX + ", " + bezierY);
		//escrevePosicao();
		window.setBezierD(x, y);
	}

	function rotacionarD(ang) {
		rotAdicionalMD += ang;
		document.getElementsByName("txtRotD")[0].value = rotAdicionalMD;
		//alert("ang = " + rotAdicionalMD);
		//escrevePosicao();
		window.setRotacaoAdicionalD(rotAdicionalMD);
	}

	function rotacionarE(ang) {
		rotAdicionalME += ang;
		document.getElementsByName("txtRotE")[0].value = rotAdicionalME;
		//alert("ang = " + rotAdicionalME);
		//escrevePosicao();
		window.setRotacaoAdicionalE(rotAdicionalME);
	}

	function setMouseAtual(num) {
		window.setMaoAtualMouse(num);
	}

	window.carregaFormDadosSequencia_js = function (nomeSequencia, restart, tempoRestart, frameRestart) {
		alert("frameRestart = " + frameRestart);
		document.getElementsByName("txtNomeSequenciaExpressao")[0].value = nomeSequencia;
		document.getElementsByName("ckRestartSeqExpr")[0].checked = restart;
		document.getElementsByName("txtTempoRestartSeqExpr")[0].value = tempoRestart;
		document.getElementsByName("txtFrameRestartSeqExpr")[0].value = frameRestart;

		alert("carregou formDados sequencia..");
	};

	window.setPosD = function(pMX, pMY) {
		posMDX = pMX;
		posMDY = pMY;
		//escrevePosicao();
	};

	window.setPosE = function(pMX, pMY) {
		posMEX = pMX;
		posMEY = pMY;
		//escrevePosicao();
	};

	window.messageBox = function (msg) {
		//alert("fuck");
		var str = String(document.getElementsByName("txtMessageBox")[0].value);
		
		var ini = str.length;
		if (str.length > 200) {
			ini = str.length - 200;
		} else {
			ini = 0;
		}
		document.getElementsByName("txtMessageBox")[0].value = str.substring(ini) + "\n" + msg;
		
		//alert("str = " + str);
		//alert("length = " + str.length);
		//document.getElementsByName("txtMessageBox")[0].SelStart = 1;
		//document.getElementsByName("txtMessageBox")[0].SelLength = 5;
		document.getElementsByName("txtMessageBox")[0].scrollTop = 99999;
	};

	function setBezierDClient (bzX, bzY) {
		//alert("bezierD x, y = " + bezierXD + ", " + bezierYD);
		//alert("bezierD x, y = ");
		bezierXD = bzX;
		bezierYD = bzY;
		//escrevePosicao();
	}

	window.setBezierEClient = function(bzX, bzY) {
		//alert("bezierE x, y = " + bezierXE + ", " + bezierYE);
		bezierXE = bzX;
		bezierYE = bzY;
		//escrevePosicao();
	};

	function trocaPosicaoBocaAET(combo) {
		window.trocaPosicaoBoca_j(combo.options[combo.selectedIndex].value);
		alteraExpressaoTmp();
	}

	function trocaEstiloBocaAET(combo) {
		window.trocaEstiloBoca_j(combo.options[combo.selectedIndex].value);
		alteraExpressaoTmp();
	}

	function trocaEstiloOlhoAET(combo) {
		window.trocaEstiloOlho_j(combo.options[combo.selectedIndex].value);
		alteraExpressaoTmp();
	}

	function trocaPosicaoOlhoAET(combo) {
		window.trocaPosicaoOlho_j(combo.options[combo.selectedIndex].value);
		alteraExpressaoTmp();
	}

	function trocaSobrancelhaAET(combo) {
		window.trocaMovimentoSobrancelha_j(combo.options[combo.selectedIndex].value);
		alteraExpressaoTmp();
	}

	function mudaVeloc(dirEsq, num, indice) {
		var veloc = parseInt(document.getElementsByName("txtVeloc" + dirEsq + "_" + indice)[0].value);
		veloc += num;
		//alert(veloc);
		document.getElementsByName("txtVeloc" + dirEsq + "_" + indice)[0].value = veloc;
	}

	function mudaVeloc(num) {
		var veloc = parseInt(document.getElementsByName("txtAET_Veloc")[0].value);
		veloc += num;
		document.getElementsByName("txtAET_Veloc")[0].value = veloc;
		alteraExpressaoTmp();
	}

	function mudaRotacao(num) {
		var rotacao = parseFloat(document.getElementsByName("txtAET_Rotacao")[0].value);
		rotacao += num;
		//alert(veloc);
		document.getElementsByName("txtAET_Rotacao")[0].value = rotacao;
		var maoAtual = document.getElementsByName("txtAET_Mao")[0].value;
		if (maoAtual == 1) {
			window.setRotacaoAdicionalD(rotacao);
		} else {
			window.setRotacaoAdicionalE(rotacao);
		}
		alteraExpressaoTmp();
	}

	function mudaBezierX(num) {
		var bezier = parseFloat(document.getElementsByName("txtAET_BezierX")[0].value);
		bezier += num;
		document.getElementsByName("txtAET_BezierX")[0].value = bezier;
		var maoAtual = document.getElementsByName("txtAET_Mao")[0].value;
		if (maoAtual == 1) {
			bezierD(num, 0);
		} else {
			bezierE(num, 0);
		}
		alteraExpressaoTmp();
	}

	function mudaBezierY(num) {
		var bezier = parseFloat(document.getElementsByName("txtAET_BezierY")[0].value);
		bezier += num;
		document.getElementsByName("txtAET_BezierY")[0].value = bezier;
		var maoAtual = document.getElementsByName("txtAET_Mao")[0].value;
		//alert("maoAtual = " + maoAtual);
		if (maoAtual == 1) {
			bezierD(0, num);
		} else {
			bezierE(0, num);
		}
		//alert("mudaBezierY ok");
		alteraExpressaoTmp();
	}

	window.carregaFormAET = function(mao, indice, maoId, subMaoId, sobrancelhaId, olhoId, bocaId, rotacao, bezierX, bezierY, veloc, riscar) {
		//alert("sobrancelhaId - " + sobrancelhaId);
		document.getElementsByName("txtAET_Mao")[0].value = mao;
		document.getElementsByName("txtAET_Indice")[0].value = indice;
		document.getElementsByName("txtAET_BezierX")[0].value = bezierX;
		document.getElementsByName("txtAET_BezierY")[0].value = bezierY;
		document.getElementsByName("txtAET_Veloc")[0].value = veloc;
		document.getElementsByName("ckAET_Riscar")[0].checked = riscar;
		//alert("teste - carregaFormAET");
		var comboMaoId = document.getElementsByName("cbAET_MaoEstilo")[0];
		comboMaoId.selectedIndex = maoId - 1;

		var comboSubMaoId = document.getElementsByName("cbAET_SubMaoId")[0];
		comboSubMaoId.selectedIndex = subMaoId - 1;
		//alert("comboMao - " + comboMao.selectedIndex);
		var comboSobrancelha = document.getElementsByName("cbAET_Sobrancelha")[0];
		comboSobrancelha.selectedIndex = sobrancelhaId;
		var comboOlho = document.getElementsByName("cbAET_PosicaoOlho")[0];
		comboOlho.selectedIndex = olhoId - 1;
		var comboBoca = document.getElementsByName("cbAET_PosicaoBoca")[0];
		comboBoca.selectedIndex = bocaId - 1;

		document.getElementsByName("txtAET_Rotacao")[0].value = rotacao;
		//alert("comboSobrancelha.selectedIndex = " + comboSobrancelha.selectedIndex);
	};

	function alteraExpressaoTmp() {
		//alert("vai salvar...1");
		var maoAtual = document.getElementsByName("txtAET_Mao")[0].value;
		
		//alert("vai salvar...2");
		var indice = document.getElementsByName("txtAET_Indice")[0].value;
		//alert("vai salvar...3");
		var riscar = document.getElementsByName("ckAET_Riscar")[0].checked;
		//alert("vai salvar...4");
		var comboEstiloMao = document.getElementsByName("cbAET_MaoEstilo")[0];
		var comboSubMao = document.getElementsByName("cbAET_SubMaoId")[0];
		var comboSobrancelha = document.getElementsByName("cbAET_Sobrancelha")[0];
		var comboEstiloOlho = document.getElementsByName("cbAET_EstiloOlho")[0];
		var comboPosicaoOlho = document.getElementsByName("cbAET_PosicaoOlho")[0];
		var comboEstiloBoca = document.getElementsByName("cbAET_EstiloBoca")[0];
		var comboPosicaoBoca = document.getElementsByName("cbAET_PosicaoBoca")[0];
		var rotacao = document.getElementsByName("txtAET_Rotacao")[0].value;
		var bezierX = document.getElementsByName("txtAET_BezierX")[0].value;
		var bezierY = document.getElementsByName("txtAET_BezierY")[0].value;
		var veloc = document.getElementsByName("txtAET_Veloc")[0].value;
		//alert("salvando AET:(" + mao + ", " + indice + ", " + (comboMao.selectedIndex + 1) + ", s:" + (comboSobrancelha.selectedIndex + 1) + ", o:" + (comboOlho.selectedIndex + 1) + ", " + rotacao + ", " + veloc + ", " + riscar + ")");
		window.alteraExpressaoTmp_j(maoAtual, indice, comboEstiloMao.selectedIndex + 1, comboSubMao.selectedIndex + 1, comboSobrancelha.selectedIndex, comboEstiloOlho.selectedIndex + 1, comboPosicaoOlho.selectedIndex + 1, comboEstiloBoca.selectedIndex + 1, comboPosicaoBoca.selectedIndex + 1, rotacao, bezierX, bezierY, veloc, riscar);
		//alert("salvou AET!");
	}

	function sendText() {
		var txt = document.getElementsByName("txtText")[0].value;
		//alert("txt = " + txt);
		//window.sendMsgText_j(txt);
		window.sendMsgText2_j(txt, true);
	}

	function aguardaBackgroundCarregado() {
		if (window.verificaBackgroundCarregado_j()) {
			window.setVisible_j(true);
			document.getElementById("divAbaixoTitulo").style.display = "block";
		} else {
			setTimeout("aguardaBackgroundCarregado();", 200);
		}
	}

	var numExpressoes = <%=listExpressao.size()%>;
	window.variavelCarregamento = 1;
</script>

<div id="playn-root" style="border: thin solid black; width: 600px; height: 300px; overflow: hidden;">
</div>

<BR>

<div id="divAlteraExpressaoTmp">
	<table>
		<tr>
			<td><input type="text" style="width: 20px;" name="txtAET_Mao" value="" disabled="disabled"></td>
			<td><input type="text" style="width: 20px;" name="txtAET_Indice" value="" disabled="disabled"></td>
			<td>
				<select name="cbAET_MaoEstilo" onchange="trocaEstiloMaoAET(this);">
					<option value="1">mao Estilo1</option>
					<option value="2">mao Estilo2</option>
					<option value="3">mao Estilo3</option>
					<option value="4">mao Estilo4</option>
					<option value="5">mao Estilo5</option>
					<option value="6">mao Estilo6</option>
					<option value="7">mao Estilo7</option>
				</select>
			</td>
			<td>
				<select name="cbAET_SubMaoId" onchange="trocaSubMaoIdAET(this);">
					<option value="1">mao1_SOCO</option>
					<option value="2">mao2_INDICANDO</option>
					<option value="3">mao3_EXIBINDO</option>
					<option value="4">mao4_ABERTA</option>
					<option value="5">mao5_APONTANDO</option>
					<option value="6">mao6_JOIA</option>		
				</select>
			</td>
			<td>
				<select name="cbAET_Sobrancelha" onchange="trocaSobrancelhaAET(this);">
					<option value="0">SOBRANCELHA_PARADA</option>
					<option value="1">SOBRANCELHA_DIREITA_ACIMA</option>
					<option value="2">SOBRANCELHA_ESQUERDA_ACIMA</option>
					<option value="3">SOBRANCELHA_AMBAS_ACIMA</option>
					<option value="4">SOBRANCELHA_AMBAS_ABAIXO</option>
					<option value="5">SOBRANCELHA_ROTACAO_BRAVO_AMBAS</option>
					<option value="6">SOBRANCELHA_ROTACAO_BONZINHO_AMBAS</option>
				</select>
			</td>
			<td>
				<select name="cbAET_EstiloOlho" onchange="trocaEstiloOlhoAET(this);">
					<option value="1">Estilo_OLHO1</option>
					<option value="2">Estilo_OLHO2</option>
					<option value="3">Estilo_OLHO3</option>
					<option value="4">Estilo_OLHO4</option>
					<option value="5">Estilo_OLHO5</option>
					<option value="6">Estilo_OLHO6</option>
					<option value="7">Estilo_OLHO7</option>
				</select>
			</td>
			<td>
				<select name="cbAET_PosicaoOlho" onchange="trocaPosicaoOlhoAET(this);">
					<option value="1">OLHO_LADO_DIREITO</option>
					<option value="2">OLHO_LADO_ESQUERDO</option>
					<option value="3">OLHO_ACIMA</option>
					<option value="4">OLHO_ABAIXO</option>
					<option value="5">OLHO_DIAGONAL_INF_DIREITA</option>
					<option value="6">OLHO_DIAGONAL_INF_ESQUERDA</option>
					<option value="7">OLHO_DIAGONAL_SUP_DIREITA</option>
					<option value="8">OLHO_DIAGONAL_SUP_ESQUERDA</option>
					<option value="9">OLHO_CENTRO</option>
				</select>
			</td>
			<td>
				<select name="cbAET_EstiloBoca" onchange="trocaEstiloBocaAET(this);">
					<option value="1">Estilo Boca 1</option>
					<option value="2">Estilo Boca 2</option>
					<option value="3">Estilo Boca 3</option>
					<option value="4">Estilo Boca 4</option>
					<option value="5">Estilo Boca 5</option>
					<option value="6">Estilo Boca 6</option>
					<option value="7">Estilo Boca 7</option>
				</select>
			</td>
			<td>
				<select name="cbAET_PosicaoBoca" onchange="trocaPosicaoBocaAET(this);">
					<option value="1">Boca_ANGUSTIADO</option>
					<option value="2">Boca_SURPRESO</option>
					<option value="3">Boca_INFELIZ</option>
					<option value="4">Boca_SATISFEITO</option>
					<option value="5">Boca_INSATISFEITO</option>
					<option value="6">Boca_FELIZ</option>
				</select>
			</td>
			<td>
				<table>
					<tr>
						<td>ROT:<input type="text" style="width: 20px;" name="txtAET_Rotacao" value=""></td>
						<td>
							<table>
								<tr><td><input type="button" value="+" onclick="mudaRotacao(0.1);"></td></tr>
								<tr><td><input type="button" value="-" onclick="mudaRotacao(-0.1);"></td></tr>
							</table>
						</td>
					</tr>
				</table>
			</td>
			<td>
				<table>
					<tr>
						<td>BX:<input type="text" style="width: 20px;" name="txtAET_BezierX" value=""></td>
						<td>
							<table>
								<tr><td><input type="button" value="+" onclick="mudaBezierX(10);"></td></tr>
								<tr><td><input type="button" value="-" onclick="mudaBezierX(-10);"></td></tr>
							</table>
						</td>
					</tr>
				</table>
			</td>
			<td>
				<table>
					<tr>
						<td>BY:<input type="text" style="width: 20px;" name="txtAET_BezierY" value=""></td>
						<td>
							<table>
								<tr><td><input type="button" value="+" onclick="mudaBezierY(10);"></td></tr>
								<tr><td><input type="button" value="-" onclick="mudaBezierY(-10);"></td></tr>
							</table>
						</td>
					</tr>
				</table>
			</td>
			<td>
				<table>
					<tr>
						<td>Veloc:<input style="width: 12px;" type="text" value="2" name="txtAET_Veloc"></td>
						<td>
							<table>
								<tr><td><input type="button" value="+" onclick="mudaVeloc(1);"></td></tr>
								<tr><td><input type="button" value="-" onclick="mudaVeloc(-1);"></td></tr>
							</table>
						</td>
					</tr>
				</table>
			</td>
			<td>Ris:<input type="checkbox" name="ckAET_Riscar" value="R"></td>
			<td><input type="button" onclick="alteraExpressaoTmp();" value="salva ExpTmp"></td>
		</tr>
	</table>
</div>

<div style="border: thin solid black; background-color: gray; font-size: 11px;">
	<div>
		<input type="button" value="Adicionar" onclick="adicionarMaisPontos();">
		<input type="button" value="Corrigir" onclick="startCorrecao();">
		<input type="button" value="Nova Gravacao" onclick="startRecording();">
		<input type="button" value="Gravar Sequencia Temporaria" onclick="gravaSequenciaGravacao();">
		<input type="text" value="" name="txtNomeSequenciaGravacao">
		<input type="button" value="Select All" onclick="selectAll(0);">
		<input type="button" value="Play" onclick="playSequenciaTemp();">
		<input type="button" value="Editar" onclick="editarSequenciaTemp();">
	</div>

	<div style="height: 200px; background-color: orange; overflow: auto;">
		<table>
			<tr>

			</tr>
				<% for (int i = 0; i < listExpressao.size(); i++) { %>
					<% PosicaoMaosDB pM = listExpressao.get(i).getPosicaoMaos(); %>
				<tr>
					<td><input type="button" value="View" onclick="carregaExpressaoByName('<%=listExpressao.get(i).getNome()%>');"></td>
					<td><input type="text" value="<%=listExpressao.get(i).getNome()%>" name="txtNomeExpr_<%=i%>"></td>
					<td><input type="text" value="1" name="txtTempo_<%=i%>" style="width: 20px;"></td>
					<td><input type="checkbox" name="ckAnimar_<%=i%>"></td>
					<td><input type="checkbox" name="ckExprTmp_<%=i%>" title="<%=listExpressao.get(i).getNome()%>" onclick="adicionaExpressaoAtual(<%=i%>, this);"></td>
					<td>
						<select name="cbSobrancelha_<%=i%>" onchange="trSobrancelha(this);">
							<% if (listExpressao.get(i).getMovimentoSobrancelha() != null) { %>
								<option <%=(listExpressao.get(i).getMovimentoSobrancelha().getId() == 0?"selected":"")%> value="0">SOBRANCELHA_PARADA</option>
								<option <%=(listExpressao.get(i).getMovimentoSobrancelha().getId() == 1?"selected":"")%> value="1">SOBRANCELHA_DIREITA_ACIMA</option>
								<option <%=(listExpressao.get(i).getMovimentoSobrancelha().getId() == 2?"selected":"")%> value="2">SOBRANCELHA_ESQUERDA_ACIMA</option>
								<option <%=(listExpressao.get(i).getMovimentoSobrancelha().getId() == 3?"selected":"")%> value="3">SOBRANCELHA_AMBAS_ACIMA</option>
								<option <%=(listExpressao.get(i).getMovimentoSobrancelha().getId() == 4?"selected":"")%> value="4">SOBRANCELHA_AMBAS_ABAIXO</option>
								<option <%=(listExpressao.get(i).getMovimentoSobrancelha().getId() == 5?"selected":"")%> value="5">SOBRANCELHA_ROTACAO_BRAVO_AMBAS</option>
								<option <%=(listExpressao.get(i).getMovimentoSobrancelha().getId() == 6?"selected":"")%> value="5">SOBRANCELHA_ROTACAO_BONZINHO_AMBAS</option>
							<% } %>
						</select>
					</td>
					<td>
						<select name="cbOlho_<%=i%>" onchange="trPosicaoOlho(this);">
							<% if (listExpressao.get(i).getPosicaoOlhoBoneco() != null) { %>
								<option <%=(listExpressao.get(i).getPosicaoOlhoBoneco().getId() == 1?"selected":"")%> value="1">OLHO_LADO_DIREITO</option>
								<option <%=(listExpressao.get(i).getPosicaoOlhoBoneco().getId() == 2?"selected":"")%> value="2">OLHO_LADO_ESQUERDO</option>
								<option <%=(listExpressao.get(i).getPosicaoOlhoBoneco().getId() == 3?"selected":"")%> value="3">OLHO_ACIMA</option>
								<option <%=(listExpressao.get(i).getPosicaoOlhoBoneco().getId() == 4?"selected":"")%> value="4">OLHO_ABAIXO</option>
								<option <%=(listExpressao.get(i).getPosicaoOlhoBoneco().getId() == 5?"selected":"")%> value="5">OLHO_DIAGONAL_INF_DIREITA</option>
								<option <%=(listExpressao.get(i).getPosicaoOlhoBoneco().getId() == 6?"selected":"")%> value="6">OLHO_DIAGONAL_INF_ESQUERDA</option>
								<option <%=(listExpressao.get(i).getPosicaoOlhoBoneco().getId() == 7?"selected":"")%> value="7">OLHO_DIAGONAL_SUP_DIREITA</option>
								<option <%=(listExpressao.get(i).getPosicaoOlhoBoneco().getId() == 8?"selected":"")%> value="8">OLHO_DIAGONAL_SUP_ESQUERDA</option>
								<option <%=(listExpressao.get(i).getPosicaoOlhoBoneco().getId() == 9?"selected":"")%> value="9">OLHO_CENTRO</option>
							<% } %>
						</select>
					</td>
					<td>
						<select name="cbBoca_<%=i%>" onchange="trPosicaoBoca(this);">
							<% if (listExpressao.get(i).getPosicaoBoca() != null) { %>
								<option <%=(listExpressao.get(i).getPosicaoBoca().getId() == 1?"selected":"")%> value="1">Boca_ANGUSTIADO</option>
								<option <%=(listExpressao.get(i).getPosicaoBoca().getId() == 2?"selected":"")%> value="2">Boca_SURPRESO</option>
								<option <%=(listExpressao.get(i).getPosicaoBoca().getId() == 3?"selected":"")%> value="3">Boca_INFELIZ</option>
								<option <%=(listExpressao.get(i).getPosicaoBoca().getId() == 4?"selected":"")%> value="4">Boca_SATISFEITO</option>
								<option <%=(listExpressao.get(i).getPosicaoBoca().getId() == 5?"selected":"")%> value="5">Boca_INSATISFEITO</option>
								<option <%=(listExpressao.get(i).getPosicaoBoca().getId() == 6?"selected":"")%> value="6">Boca_FELIZ</option>
							<% } %>
						</select>
					</td>

					<td>XD:<%=listExpressao.get(i).getPosicaoMaos().getPosMDX()%>|</td>
					<td>YD:<%=listExpressao.get(i).getPosicaoMaos().getPosMDY()%>|</td>
					<td>XE:<%=listExpressao.get(i).getPosicaoMaos().getPosMEX()%>|</td>
					<td>YE:<%=listExpressao.get(i).getPosicaoMaos().getPosMEY()%>|</td>

					<td><input type="button" value="+" onclick="mudaVeloc('D', 1, <%=i%>);"></td>
					<td><input style="width: 12px;" type="text" value="<%=listExpressao.get(i).getVelocidadeD()%>" name="txtVelocD_<%=i%>"></td>
					<td><input type="button" value="-" onclick="mudaVeloc('D', -1, <%=i%>);"></td>
					<td><input type="button" value="+" onclick="mudaVeloc('E', 1, <%=i%>);"></td>
					<td><input style="width: 12px;" type="text" value="<%=listExpressao.get(i).getVelocidadeE()%>" name="txtVelocE_<%=i%>"></td>
					<td><input type="button" value="-" onclick="mudaVeloc('E', -1, <%=i%>);"></td>
					<td>RotAdicMD:<input type="text" name="rotMD_<%=i%>" value="<%=pM.getRotacaoAdicionalMaoD()%>" style="width: 10px;"></td>
					<td>RotAdicME:<input type="text" name="rotME_<%=i%>" value="<%=pM.getRotacaoAdicionalMaoE()%>" style="width: 10px;"></td>
					<td><input type="checkbox" value="RD" <%=(listExpressao.get(i).getRiscarD()?"checked":"")%> name="ckRiscarD_<%=i%>"></td>
					<td><input type="checkbox" value="RE" <%=(listExpressao.get(i).getRiscarE()?"checked":"")%> name="ckRiscarE_<%=i%>"></td>

					<td><input type="button" value="salva" onclick="salvaExpressaoInd(<%=i%>, <%=pM.getSubMaoDId()%>, <%=pM.getSubMaoEId()%>, <%=pM.getPosMDX()%>, <%=pM.getPosMDY()%>, <%=pM.getPosMEX()%>, <%=pM.getPosMEY()%>, <%=pM.getBezierDX()%>, <%=pM.getBezierDY()%>, <%=pM.getBezierEX()%>, <%=pM.getBezierEY()%>);"></td>
				</tr>
			<% } %>
		</table>
	</div>

	<div>
		<input type="button" value="SalvaSequenciaExpressao" onclick="salvaSequenciaExpressao();">
		<input type="text" name="txtNomeSequenciaExpressao" value="">
		<select name="cbSequenciaExpressaoDB" onchange="carregaSequenciaExpressao(this);">
			<option></option>
			<% for (int i = 0; i < listSeqExpressao.size(); i++) { %>
				<option><%=listSeqExpressao.get(i).getNome()%></option>
			<% } %>
		</select>
		<select name="cbEditarSequenciaExpressaoDB" onchange="editarSequenciaExpressao(this);">
			<option></option>
			<% for (int i = 0; i < listSeqExpressao.size(); i++) { %>
				<option><%=listSeqExpressao.get(i).getNome()%></option>
			<% } %>
		</select>
		Reestart:<input type="checkbox" name="ckRestartSeqExpr" onchange="salvaReestartSequenciaExpressao(this);">
		Frame:<input type="text" name="txtFrameRestartSeqExpr">
		<input type="text" name="txtTempoRestartSeqExpr">
		<input type="button" value="del Expr" onclick="deletaSequenciaExpressao();">
		<input type="button" value="Del All" onclick="deletaTodasExpressoes();">
	</div>
</div>

<BR>

<div style="position: absolute; top:10px; left: 700px; width: 300px; height: 290px; border: thin solid red;">
	<div style="background-color: green; float: left; width: 48%;">
		<table>
			<tr>
				<td>
					<input type="button" value="PosBonecoX+" onclick="addPosicaoBoneco(+10, 0);">
				</td>
				<td>
					<input type="button" value="PosBonecoX-" onclick="addPosicaoBoneco(-10, 0);">
				</td>
			</tr>
		</table>
	</div>
	<div style="background-color: red; width: 48%; right: 0px; float: left;">
		<table>
			<tr>
				<td>
					<input type="button" value="PosBonecoY+" onclick="addPosicaoBoneco(0, +10);">
				</td>
				<td>
					<input type="button" value="PosBonecoY-" onclick="addPosicaoBoneco(0, -10);">
				</td>
			</tr>
		</table>
	</div>
	<div style="background-color: green; float: left; width: 48%;">
		<table>
			<tr>
				<td>
					<select name="cbMaoE" onchange="trocaMao(2, this);">
						<option value="1">mao1</option>
						<option value="2">mao2</option>
						<option value="3">mao3</option>
						<option value="4">mao4</option>
						<option value="5">mao5</option>
						<option value="6">mao6</option>
						<option value="7">mao7</option>
						<option value="8">mao8</option>
						<option value="9">mao9</option>
					</select>
				</td>
			</tr>
			<tr>
				<td><input type="button" value="E" onclick="setMouseAtual(2);"></td>
			</tr>
		</table>
	</div>
	<div style="background-color: red; width: 48%; right: 0px; float: left;">
		<table>
			<tr>
				<td>
					<select name="cbMaoD" onchange="trocaMao(1, this);">
						<option value="1">mao1</option>
						<option value="2">mao2</option>
						<option value="3">mao3</option>
						<option value="4">mao4</option>
						<option value="5">mao5</option>
						<option value="6">mao6</option>
						<option value="7">mao7</option>
						<option value="8">mao8</option>
						<option value="9">mao9</option>
					</select>
				</td>
			</tr>
			<tr>
				<td><input type="button" value="D" onclick="setMouseAtual(1);"></td>
			</tr>
		</table>
	</div>
	<div style="background-color: green; width: 48%; float: left;">
		<table>
			<tr>
			<td>
					<table>
						<tr>
							<td><input type="button" value="+BZXE" onclick="bezierE(10, 0);"></td>
						</tr>
						<tr>
							<td><input type="button" value="-BZXE" onclick="bezierE(-10, 0);"></td>
						</tr>
					</table>
				</td>
				<td>
					<table>
						<tr>
							<td><input type="button" value="+BZYE" onclick="bezierE(0, 10);"></td>
						</tr>
						<tr>
							<td><input type="button" value="-BZYE" onclick="bezierE(0, -10);"></td>
						</tr>
					</table>
				</td>
				<td>
					<table>
						<tr>
							<td><input type="button" value="+RTE" onclick="rotacionarE(0.1);"></td>
						</tr>
						<tr>
							<td><input type="button" value="-RTE" onclick="rotacionarE(-0.1);"></td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
	</div>

	<div style="background-color: red; width: 48%; float: left;">
		<table>
			<tr>
				<td>
					<table style="margin: 0px; padding: 0px;">
						<tr>
							<td><input class="fontBotaoSmall" type="button" value="+BZXD" onclick="bezierD(10, 0);"></td>
						</tr>
						<tr>
							<td><input type="button" value="-BZXD" onclick="bezierD(-10, 0);"></td>
						</tr>
					</table>
				</td>
				<td>
					<table>
						<tr>
							<td><input type="button" value="+BZYD" onclick="bezierD(0, 10);"></td>
						</tr>
						<tr>
							<td><input type="button" value="-BZYD" onclick="bezierD(0, -10);"></td>
						</tr>
					</table>
				</td>
				<td>
					<table>
						<tr>
							<td><input type="button" value="+RTD" onclick="rotacionarD(0.1);"></td>
						</tr>
						<tr>
							<td><input type="button" value="-RTD" onclick="rotacionarD(-0.1);"></td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
	</div>

	<div style="width:100%;">
		<table style="width:100%;">
			<tr>
				<td>
					<select name="cbSobrancelha" onchange="trSobrancelha(this);" style="width:100%;">
						<option value="0">SOBRANCELHA_PARADA</option>
						<option value="1">SOBRANCELHA_DIREITA_ACIMA</option>
						<option value="2">SOBRANCELHA_ESQUERDA_ACIMA</option>
						<option value="3">SOBRANCELHA_AMBAS_ACIMA</option>
						<option value="4">SOBRANCELHA_AMBAS_ABAIXO</option>
						<option value="5">SOBRANCELHA_ROTACAO_BRAVO_AMBAS</option>
						<option value="5">SOBRANCELHA_ROTACAO_BONZINHO_AMBAS</option>
					</select>
				</td>
			</tr>
			<tr>
				<td>
					<select name="cbOlho" onchange="trPosicaoOlho(this);" style="width:100%;">
						<option value="0">OLHO_LADO_DIREITO</option>
						<option value="1">OLHO_LADO_ESQUERDO</option>
						<option value="2">OLHO_ACIMA</option>
						<option value="3">OLHO_ABAIXO</option>
						<option value="4">OLHO_DIAGONAL_INF_DIREITA</option>
						<option value="5">OLHO_DIAGONAL_INF_ESQUERDA</option>
						<option value="6">OLHO_DIAGONAL_SUP_DIREITA</option>
						<option value="7">OLHO_DIAGONAL_SUP_ESQUERDA</option>
					</select>
				</td>
			</tr>
			<tr>
				<td>
					<select name="cbBoca" onchange="trPosicaoBoca(this);" style="width:100%;">
						<option value="0">Boca_ANGUSTIADO</option>
						<option value="1">Boca_SURPRESO</option>
						<option value="2">Boca_INFELIZ</option>
						<option value="3">Boca_SATISFEITO</option>
						<option value="4">Boca_INSATISFEITO</option>
						<option value="5">Boca_FELIZ</option>
					</select>
				</td>
			</tr>
			<tr>
				<td>
					Riscar:<input type="checkbox" name="ckRiscar" onchange="trocaRiscar(this);">
				</td>
			</tr>
		</table>
	</div>

	<div style="width:100%;">
		<input type="text" name="txtText" value="">
		<input type="button" value="Send" name="btnSendText" onclick="sendText();">
	</div>

	<div style="width: 98%;">
		<textarea name="txtMessageBox" cols="30" rows="5" style="width: 100%;"></textarea>
	</div>
</div>

<br>

<input type="button" value="SalvaPosicaoMaos" onclick="salvaPosicaoM();">
<input type="text" name="txtNomePM" value="">
<select name="cbPosicaoMaosDB" onchange="carregaPosicaoM(this);">
	<% for (int i = 0; i < listPosicaoMaos.size(); i++) { %>
		<option><%=listPosicaoMaos.get(i).getNome()%></option>
	<% } %>
</select>
<input type="button" value="del PM" onclick="deletaPosicaoM();">
<input type="button" value="del All" onclick="deletaTodasPosicoesMaos();">

<br>

<input type="button" value="SalvaExpressao" onclick="salvaExpressao();">
<input type="text" name="txtNomeExpressao" value="">
<select name="cbExpressaoDB" onchange="carregaExpressao(this);">
	<% for (int i = 0; i < listExpressao.size(); i++) { %>
		<option><%=listExpressao.get(i).getNome()%></option>
	<% } %>
</select>
<input type="button" value="del Expr" onclick="deletaExpressao();">

<br>

<!-- <input type="text" value="" name="txtTempo">  -->
<!-- <input type="button" value="AdicionaExpressaoAtual" onclick="adicionaExpressaoAtual();">  -->

<table>
	<tr>
		<td>
			<select name="cbPosMaos" onchange="trocaPosMaos(this);">
				<option value="0">DUAS_MAOS_APONTANDO_ABAIXO</option>
				<option value="1">DUAS_MAOS_NA_CABECA</option>
				<option value="2">DUAS_MAOS_APONTANDO_ACIMA</option>
				<option value="3">DUAS_MAOS_APONTANDO_DIREITA</option>
				<option value="4">DUAS_MAOS_APONTANDO_ESQUERDA</option>
				<option value="5">BANANA</option>
			</select>
		</td>
		<td>
			<select name="cbExpressao" onchange="trocaPosExpressao(this);">
				<option value="0">EXPRESSAO_1</option>
				<option value="1">EXPRESSAO_2</option>
				<option value="2">EXPRESSAO_3</option>
				<option value="3">EXPRESSAO_4</option>
				<option value="4">EXPRESSAO_5</option>
				<option value="5">EXPRESSAO_6</option>
			</select>
		</td>
		<td>
			<select name="cbSequenciaExpressao" onchange="trocaSeqExpressao(this);">
				<option value="-1"></option>
				<option value="0">TCHAUZINHO</option>
				<option value="1">MOVIMENTO_1</option>
				<option value="2">MOVIMENTO_2</option>
			</select>
		</td>
	</tr>
</table>

<table>
	<tr>
		<td>
			<table>
				<tr>
					<td><input type="text" name="txtXD" value="130"></td>
					<td><input type="text" name="txtYD" value="130"></td>
					<td><input type="text" name="txtRotD" value="0"></td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td>
			<table>
				<tr>
					<td><input type="text" name="txtXE" value="130"></td>
					<td><input type="text" name="txtYE" value="130"></td>
					<td><input type="text" name="txtRotE" value="0"></td>		
				</tr>
			</table>
		</td>
	</tr>
</table>

Posicao: <input type="text" name="txtNovaPosicao" value="" style="width: 400px;">
Expressao: <input type="text" name="txtNovaExpressao" value="" style="width: 400px;">

<select name="cbAleatorio" onchange="trocaAnimAleatoria(this);">
	<option value="0">Sem Animacao</option>
	<option value="1">Expressao e Face</option>
	<option value="2">Expressao</option>
	<option value="3">Face</option>
</select>

<button onclick="iniciarComportamentoAleatorio();">Iniciar comportamento Aleatorio</button>

<script type="text/javascript" src='/qualomelhor.gwt.modules.TestePlayN/qualomelhor.gwt.modules.TestePlayN.nocache.js'></script>

<script type="text/javascript">
	function setGameBack(imageUrl) {
		//alert("imageUrl = " + imageUrl);
		if (window.verificaGameCarregado_j && window.verificaGameCarregado_j()) {
			//alert("verificaGameCarregado_j carregado.." + window.verificaGameCarregado_j());
			window.carregaSequenciaExpressao_j("Bem-Vindo", true);
			window.setBackground_j(imageUrl);
			setTimeout("aguardaBackLoaded();", 1000);
			//alert("executou!");
		} else {
			setTimeout("setGameBack('" + imageUrl + "');", 2000);
		}
	}
	
	setGameBack("/images/background/fundobase.png");

	function aguardaBackLoaded() {
		//alert("aguardando...");
		if (window.verificaBackgroundCarregado_j && window.verificaBackgroundCarregado_j()) {
			window.setVisible_j(true);
			$("#divAbaixoTitulo").css("visibility", "visible");
			window.habilitaMouseClicks_j();
			window.setButtonsTrocaVisible_j(true);
			//alert("left = " + $("#playn-root").offset().left);
			//alert("moveu!");
		} else {
			setTimeout("aguardaBackLoaded();", 200);
		}
	}
	
	//alert("carregou!");
</script>